from selenium import webdriver
import time

from selenium.webdriver.common.by import By


class Ecshop:
    # 初始化实例对象
    def __init__(self):
       self.driver =webdriver.Chrome()
# 1. 首页搜索操作

    def search(self):
        #找到首页网址
        self.driver.get('https://ecshop.test2.shopex123.com/')
        #定位搜索框,写入文本信息
        self.driver.find_element(By.XPATH,"// *[ @ id = 'keyword']").send_keys('资生堂')


    def diwei(self):
        self.driver.find_element(By.CSS_SELECTOR,"input[type*='submit']").click()
        if '资生堂' in self.driver.title:
            print('找到了')
        else:
            print('没有找到')





# 2. 注册操作


# 3. 登录操作


    def quit(self):
        time.sleep(3)
        self.driver.quit()





if __name__ == '__main__':
    su= Ecshop()
    su.search()
    su.diwei()
    su.quit()